<template>
    <div v-if="project != undefined" class="p-3">
        <el-text size="large" tag="b">项目名称：{{project.name}}</el-text>
    </div> 
</template>
<script setup lang="ts">
    import { ref, reactive, watchEffect, onMounted } from 'vue'
    import { QueryByCode } from '@/api/common/dueDiligenceProject.js'

    const props = defineProps({
		projectCode: {
			type: String,
			required: true
		}
    })

    const project = ref()

     /**
     * 1.watch: 既要指明监视的属性，也要指明监视的回调。
     * 2.watchEffect: 不用指明监视哪个属性，监视的回调中用到哪个属性，那就监视哪个属性。
     */
     watchEffect(() => {
        if(props.projectCode) {
            QueryByCode(props.projectCode)
                .then((response) => {
                    project.value = response.data.records[0]
                }).catch(()=>{})
        }
        
    })

</script>
<style scoped></style>